package leetcode;

import list.LinkedListCreate;
import list.ListNode;

public class SwapPairsListNode {

	public static void main(String[] args) {
		int[] array = {1,2,3,4,5,6,7,8,9,19};
		ListNode head = LinkedListCreate.createList(array);
		head = swapPairs(head);
		LinkedListCreate.printList(head);
	}
	public static ListNode swapPairs(ListNode head) {
		if(head == null || head.next == null){
			return head;
		}
		ListNode temp = head.next;
		head.next = head.next.next;  //head的next指针首先指向下下个
		temp.next = head;
		head.next = swapPairs(head.next);
		return temp;
	}
}
